package domfarr.tapestry.pages;

import org.apache.tapestry5.SelectModel;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.ioc.Messages;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.util.EnumSelectModel;

import domfarr.tapestry.model.Country;
import domfarr.tapestry.model.Gender;

public class Register {
	@Persist
	private Country country;
	private String email;
	private Gender gender;
	@Inject
	private Messages messages;
	private String password;
	private String password2;
	@Persist
	private boolean subscribe;

	private boolean unsubscribe;

	private String userName;

	public SelectModel getCountries() {
		return new EnumSelectModel(Country.class, messages);
	}

	public Country getCountry() {
		return country;
	}

	public String getEmail() {
		return email;
	}

	public Gender getFemale() {
		return Gender.FEMALE;
	}

	public Gender getGender() {
		return gender;
	}

	public Gender getMale() {
		return Gender.MALE;
	}

	public String getPassword() {
		return password;
	}

	public String getPassword2() {
		return password2;
	}

	public String getUserName() {
		return userName;
	}

	public boolean isSubscribe() {
		return subscribe;
	}

	public boolean isUnsubscribe() {
		return unsubscribe;
	}

	void onSubmitFromRegistrationForm() {
		System.out.println("The form was submitted!");
		if (unsubscribe) {
			subscribe = false;
		}
	}

	public void setCountry(Country country) {
		this.country = country;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public void setGender(Gender gender) {
		System.out.println("Setting gender: " + gender);
		this.gender = gender;
	}

	public void setPassword(String password) {
		System.out.println("Setting password: " + password);
		this.password = password;
	}

	public void setPassword2(String password2) {
		this.password2 = password2;
	}

	public void setSubscribe(boolean subscribe) {
		System.out.println("Setting subscribe: " + subscribe);
		this.subscribe = subscribe;
	}

	public void setUnsubscribe(boolean unsubscribe) {
		this.unsubscribe = unsubscribe;
	}

	public void setUserName(String userName) {
		System.out.println("Setting user name: " + userName);
		this.userName = userName;
	}
}
